//
//  PlayAboutClassViewController.m
//  Products_B
//
//  Created by lanou on 16/5/30.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "PlayAboutClassViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface PlayAboutClassViewController ()
@property (nonatomic, strong) AVPlayer *player;
@end

@implementation PlayAboutClassViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

    
    AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:_dishUrlString]];
    _player = [[AVPlayer alloc] initWithPlayerItem:item];
    [self.player replaceCurrentItemWithPlayerItem:item];
    
    AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:_player];
    layer.videoGravity = AVLayerVideoGravityResize;
    layer.frame = [UIScreen mainScreen].bounds;
    layer.backgroundColor = [UIColor orangeColor].CGColor;
    [self.view.layer addSublayer:layer];
    
    [self.player play];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(10, 10, 60, 30);
    [backButton setTitle:@"<-" forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
}

- (void)backButtonAction:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
